﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DAO;
using FDeal.PH_NguoiDung;
using FDeal.WUC;

namespace FDeal
{
    public partial class MemberMuahang_3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string iddeal = Request.QueryString["id"].ToString();

                LoadThongTinMuaHang();

                ImageButton1.PostBackUrl += iddeal;
                QuayLai.NavigateUrl += iddeal;

                //Lưu tạm đơn hàng mới  
                DonHangTam.diachinhan = DiaChi.Text;
                DonHangTam.tinhthanh = ThanhPho.Text.Substring(0, 4);
                DonHangTam.quan = Quan.Text.Substring(0, 4);
            }
        }

        private void LoadThongTinMuaHang()
        {
            ThongTinTaiKhoanBUS tt = new ThongTinTaiKhoanBUS();
            THONGTINTAIKHOAN taikhoan = DangNhap.current;

            HoTen.Text = taikhoan.HOTEN;
            DienThoai.Text = taikhoan.DIENTHOAI;

            //Load cac TP
            ThanhPhoBUS tpbus = new ThanhPhoBUS();
            List<THANHPHO> dstp = tpbus.LietKe();
            List<string> kq = new List<string>();

            foreach (THANHPHO tp in dstp)
            {
                kq.Add(tp.IDTHANHPHO + "|" + tp.TENTHANHPHO);
            }
            
            ThanhPho.DataSource = kq;
            ThanhPho.DataBind();

            //Load cac Quan
            QuanBUS qbus = new QuanBUS();
            List<QUAN> dsq = qbus.LietKe();
            List<string> kqq = new List<string>();

            foreach (QUAN q in dsq)
            {
                kqq.Add(q.IDQUAN + "|" + q.TENQUAN);
            }

            Quan.DataSource = kqq;
            Quan.DataBind();
        }
       
        protected void ThanhPho_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }
    }
}